﻿//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using Excel.Expressions.Compiler;
using Expressions.Compiler;
using Expressions.Compiler.Interfaces;

namespace Excel.Expressions
{
    internal partial class Nonterminals
    {
        private static Rules<char> _cell_assigment_expression()
        {
            return new Rules<char>()
            {
                () => cell_reference[false] + '=' + cell_expression[false]
            };
        }
    }

    internal partial class Expressions
    {
        private static Func<CellExpression, IExpressionTree<char>, CellExpression> _cell_assigment_expression()
        {
            return (a, b) =>
            {
                if (b[0].Context.Token.Equals(Nonterminals.cell_reference) && b[1].Context.Token.Equals('=') && b[2].Context.Token.Equals(Nonterminals.cell_expression))
                {
                    return new Assignment(cell_reference[a, b[0]], cell_expression[a, b[2]], b[2].Context.ToString());
                }
                throw new NotSupportedException("Input token is not supported");
            };
        }
    }
}
